//
//  WBUserAccount.swift
//  weibo
//
//  Created by yanghong on 15/12/7.
//  Copyright © 2015年 杨鸿. All rights reserved.
//

import UIKit

class WBUserAccount: NSObject, NSCoding {
    
    
    var expires_in: NSTimeInterval = 0 {
     
        didSet{
        
        expiresDate = NSDate(timeIntervalSinceNow: expires_in)
        
        }
    
    }
    var remind_in: String?
    var access_token: String?
    var uid: String?
    var avatar_large: String?
    var screen_name: String?
    var expiresDate:NSDate?
    init(dict: [String: AnyObject]) {
        super.init()
      setValuesForKeysWithDictionary(dict)
        
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {}
    
    override var description: String {
    
       let keys = ["expires_in","remind_in","access_token","uid","screen_name","avatar_large"]
        
        return dictionaryWithValuesForKeys(keys).description
    
    }
    func encodeWithCoder(aCoder: NSCoder){
        
        aCoder.encodeObject(uid, forKey: "uid")
        aCoder.encodeObject(expiresDate, forKey: "expiresDate")
        aCoder.encodeObject(access_token, forKey: "access_token")
        aCoder.encodeObject(avatar_large, forKey: "avatar_large")
        aCoder.encodeObject(screen_name, forKey: "screen_name")
    
    }
    required init?(coder aDecoder: NSCoder) {
        
        uid = aDecoder.decodeObjectForKey("uid") as? String
        expiresDate = aDecoder.decodeObjectForKey("expiresDate") as? NSDate
        access_token = aDecoder.decodeObjectForKey("access_token") as? String
        avatar_large = aDecoder.decodeObjectForKey("avatar_large") as? String
        screen_name = aDecoder.decodeObjectForKey("screen_name") as? String

    }
    
    
   

}
